#ifndef _BUOLA_GL_CGLYPHCACHE_H_
#define _BUOLA_GL_CGLYPHCACHE_H_

#include <buola/image/format.h>
#include <buola/image/glyph.h>
#include <buola/container/c2dtree.h>
#include <buola/gl/ctexture.h>

namespace buola { namespace gl {

class CGlyphCache
{
public:
    CGlyphCache();
    ~CGlyphCache()=default;
    
    void AddGlyph(img::CScaledGlyph *pGlyph);
    CRect_f GetRect(img::CScaledGlyph *pGlyph);
    
    void PinGlyph(img::CScaledGlyph *pGlyph)
    {
        mTree.Pin(*pGlyph->mCacheEntry);
    }

    CTexture &Texture() {   return mTexture;    }

    size_t size()   {   return mSize;   }
    
private:
    C2DTree<img::CGlyphCacheEntry> mTree;
    CTexture mTexture;
    size_t mSize;
};

/*namespace buola*/ } /*namespace buola*/ }

#endif